<?php
//-----------------------------------------------------------------
$fn=basename($_SERVER['SCRIPT_FILENAME']);
if($fn!='main.php'&&$fn!='shop.php')
	include_once($config['webroot'].'/lang/'.$config['language'].'/front.php');
if(!empty($_GET['m']))
	@include('module/'.$_GET['m'].'/lang/'.$config['language'].'.php');

$tpl->assign("lang",$lang);
$tpl->assign("sname",$fn);
if($config['temp'] == 'wap'){
	include_once($config['webroot'].'/lib/Jsdk/Jssdk.class.php');
	$jsdk = new Jssdk("wxf2ea8fb4e25f0abf","51de1a5a13cecd78c6321f0341495ca6");
	$package = $jsdk->getSignPackage();
	$tpl->assign("package", $package);
}


//-----------------------------------------------------------------
$sql = "select * from ".WEBCONGROUP." where lang = '{$config[language]}' order by sort asc ";
$db->query($sql);
$web_group = $db->getRows();

foreach($web_group as $key => $val){
	$db->query("select * from ".WEBCON." where con_group = '{$val['id']}' and con_statu = 1  ");
	$web_con[$val['title']] = $db->getRows();

}

$tpl->assign('web_con',$web_con);

$link_sql = "select * from ".LINK." where statu = 1";
$db->query($link_sql);
$web_link = $db->getRows();
//var_dump($web_link);exit;
$tpl->assign('web_link',$web_link);
//====================================城市分站================================
$city_sql = "select * from ".DOMAIN." where isopen=1 and dtype=1";
$db->query($city_sql);
$sub_city = $db->getRows();
$tpl->assign("sub_city",$sub_city);

//------------------------------------------------------------------
if(!empty($config['copyright']))
{

	$tpl->assign("bt",$config['copyright']);
}
$tpl->assign("config",$config);
//==================================================================
if($config['rewrite']>0)
{
	if($config['rewrite']==1)
	{
		$searcharray[] = "/\/\?m=(\w+)&s=(\w+)&id=(\w+)/";
		$searcharray[] = "/\/\?m=(\w+)&s=(\w+)/";
		$searcharray[] = "/\/\?m=(\w+)/";
		$searcharray[] ="/shop\.php\?uid=(\w+)&action=(\w+)&id=(\w+)&m=(\w+)/";
		$searcharray[] ="/shop\.php\?uid=(\w+)&action=(\w+)&m=(\w+)/";
		$searcharray[] ="/shop\.php\?uid=(\w+)/";

		$replacearray[] = "/\\1-\\2-\\3.html";
		$replacearray[] = "/\\1-\\2.html";
		$replacearray[] = "/\\1.html";
		$replacearray[] = "shop-\\1-\\2-\\3-\\4.html";
		$replacearray[] = "shop-\\1-\\2-\\3.html";
		$replacearray[] = "shop-\\1.html";
	}
	function rewrite($output, &$smarty)
	{
		global $searcharray,$replacearray;
		return preg_replace($searcharray, $replacearray, $output);
	}
	$tpl->register_outputfilter("rewrite");
}
if(isset($mlang))
	$tpl->register_outputfilter("translate");
?>